import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.Random;
import java.util.Scanner;

public class z1 {
    public static void main(String[] args) throws IOException {
        FileOutputStream fos = new FileOutputStream("D:\\杂论\\6.in");
        Scanner sc = new Scanner(System.in);
        StringBuilder sb = new StringBuilder();
        int n = sc.nextInt();
        sb.append(n + "\n");

        Random random = new Random();
        for (int i = 1; i <= n; i++) {
            int choice = random.nextInt(2);  // 生成0或1的随机数

            if (choice == 0) {
                char c = (char)('A' + random.nextInt(26));  // 生成大写字母
                sb.append(c);
            } else {
                char c = (char)('a' + random.nextInt(26));  // 生成小写字母
                sb.append(c);
            }
        }
        sb.append("\n");

        //开始生成t次改变
        int t = sc.nextInt();
        sb.append(t);
        sb.append("\n");

        for(int i = 1; i <= t; ++ i ) {
            int op = random.nextInt(3) + 1;
            if(op == 1) {
                int p = random.nextInt(n) + 1;
                int choice = random.nextInt(2);  // 生成0或1的随机数
                sb.append(op + " " + p + " ");
                if (choice == 0) {
                    char c = (char)('A' + random.nextInt(26));  // 生成大写字母
                    sb.append(c + "\n");
                } else {
                    char c = (char)('a' + random.nextInt(26));  // 生成小写字母
                    sb.append(c + "\n");
                }
            } else {
                sb.append(op);
                sb.append("\n");
            }
        }
        byte[] bytes = sb.toString().getBytes(StandardCharsets.UTF_8);
        fos.write(bytes);
        fos.close();
    }
}
